package com.xiaoma.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * newSingleThreadExecutor 也可以实现线程顺序执行
 */
public class TestnewFixedThreadPool {

  public static void main(String[] args) {

    ExecutorService executorService = Executors.newSingleThreadExecutor();
    for (int i = 0; i < 10; i++) {

      int finalI = i;
      executorService.execute(new Runnable() {
        @Override
        public void run() {
          System.out.println(finalI);
        }
      });
    }

  }
}
